#include<stdio.h>
#include<algorithm>
int n,l,r,m=0;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	for(int i=l;i<=r;i++)
		m=std::max(m,i%n);
	printf("%d\r",m);
}
